
package com.work.mvc.view.panels;

import java.util.Date;

import com.vaadin.ui.*;
import com.work.constants.view.ComponentsSize;
import com.work.db.DaoFactoryImpl;
import com.work.db.entity.Employer;
import com.work.util.AppUtils;

public class ContentPanel extends VerticalLayout {

	private static final long serialVersionUID = 4114063900824977242L;

	private static ContentPanel instance = new ContentPanel();

	public static ContentPanel getInstance()
	{
		if (instance == null) {
			instance = new ContentPanel();
		}
		return instance;
	}

	public ContentPanel()
	{
		init();
	}

	private void init()
	{
		this.setHeight(ComponentsSize.FULL);
		this.setMargin(true);
		
		Employer employer = DaoFactoryImpl.instance().getEmployerDao().findByShortName("IST");
		WorkTimeView component = (WorkTimeView) ContentFactory.getInstance().createContent(ContentPanelsEnum.WORKTIME_PANEL);
		component.createTabSheets(AppUtils.getYear(new Date()), employer);
		
		this.addComponent(component);
	}

	public static void changeContent(Component component)
	{
		instance.removeAllComponents();
		instance.addComponent(component);
	}
}
